package org.tokaf.normalizer.ordering;

/**
 * <p> OnePeakOrdering associated best rating with given optimum-peak. With
 * increasing distance from peak, rating lowers.</p> <p>Copyright (c) 2006</p>
 * @author Alan Eckhardt
 * @version 1.0
 */
public class OnePeakOrdering implements Ordering {
	double peak;

	double multiplication;

	public OnePeakOrdering(double peak) {
		this.peak = peak;
		if (peak >= 0.5) {
			multiplication = 1 / peak;
		} else if (peak <= 0.5) {
			multiplication = 1 / (1 - peak);
		}
	}

	public double order(double d) {
		return 1 - multiplication * (Math.abs(d - peak));
	}
}
